import { Component, OnInit, Input } from '@angular/core';
import { AppGlobalService } from '../../shared/service/app-global.service';

@Component({
  selector: 'app-information-entry',
  templateUrl: './information-entry.component.html',
  styleUrls: ['./information-entry.component.scss'],
})
export class InformationEntryComponent implements OnInit {
  @Input() tagData: any;
  listdata: any;
  liststyle ;
  liststyles: any = {};
  cssStr: any = {};
  constructor(private appGlobalService: AppGlobalService) { }

  ngOnInit() {
    this.listdata = this.tagData.data;
    this.listdata.forEach(element => {
      if ( element.style ) {
        this.liststyle = element.style;
      } else {
       /*  this.liststyle = ""; */
      }
    });
    if ( this.liststyle ) {
        // 取字段分号前的为一组
      const liststylecss = this.liststyle.split(";");
      // 每组的值存入对象
      // tslint:disable-next-line: prefer-for-of
      for (let i = 0; i < liststylecss.length; i++) {
        const x = liststylecss[i].split(":");
        console.log(x);
        this.liststyles[x[0]] = x[1];
      }
    }
  }
  skipclick(obj) {
    if (obj) {
      const pageParams = {
        pageId: obj.target,
        params: obj.params,
        sessionId: localStorage.getItem('sessionId')
      };
      console.log(pageParams);
      this.appGlobalService.goToForward(pageParams);
    }
  }
}
